package io;

import java.io.*;

/**
 * 写入，每次写一个字符
 */
public class OutputStreamDemo1 {
    public static void main(String[] args) throws IOException {
        File file=new File("mytest.txt");
        if(!file.exists()){
            //新建文件
            System.out.println("新建文件夹："+file.createNewFile());
        }
        //文件写入操作
        try(OutputStream outputStream=new FileOutputStream(file)){
            outputStream.write('h');
            outputStream.write('e');
            outputStream.write('l');
            outputStream.write('l');
            outputStream.write('o');

            outputStream.flush();
        }
    }
}
